/** 
const redux = require("redux")

// reducer
const defaultState = {
    counter: 0
};
let reducer = function (state = defaultState, action) {
    switch (action.type) {
        case "ADD_NUMBER":
            // let tmp = {...state}
            // tmp.counter = state.counter + action.number
            return {...state, counter: state.counter + action.number}
        default:
            return state
    }
}

// store
let store = redux.createStore(reducer)
store.subscribe(() => {
    console.log("发送了" + store.getState().counter)
})

store.subscribe(() => {
    console.log("是的" + store.getState().counter)
})

// actionCreator
function addAction(number) {
    return {
        type: "ADD_NUMBER",
        number: number
    }
}
store.dispatch(addAction(1))
store.dispatch(addAction(3))
*/

import store from "./store/index.js";
import addAction from "./store/actionCreators.js";

let unsubscribe = store.subscribe(() => {
    console.log("是的" + store.getState().counter)
})

store.dispatch(addAction(1))
store.dispatch(addAction(1))

unsubscribe();